'HIDEasy
'Copyright (C) 2011 ASFX

'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.

'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Imports USAGE = System.UInt16

<CLSCompliant(False)> _
Public Class HIDDeviceCapabilities
    Private _capa As HIDClass.HIDP_CAPS
    Private _UsagePageString As String = "(unknown)"
    Private _UsageIDString As String = "(unknown)"

    Friend Sub New(ByVal capabilities As HIDClass.HIDP_CAPS)
        _capa = capabilities

        _UsagePageString = GetUsagePageString(_capa.UsagePage)
        _UsageIDString = GetUsageIDString(_capa.UsagePage, _capa.Usage)

    End Sub

    ReadOnly Property Usage() As USAGE
        Get
            Return _capa.Usage
        End Get
    End Property

    ReadOnly Property UsagePage() As USAGE
        Get
            Return _capa.UsagePage
        End Get
    End Property

    ReadOnly Property InputReportByteLength() As UShort
        Get
            Return _capa.InputReportByteLength
        End Get
    End Property

    ReadOnly Property OutputReportByteLength() As UShort
        Get
            Return _capa.OutputReportByteLength
        End Get
    End Property

    ReadOnly Property FeatureReportByteLength() As UShort
        Get
            Return _capa.FeatureReportByteLength
        End Get
    End Property

    Private ReadOnly Property Reserved() As Short()
        Get
            Return _capa.Reserved
        End Get
    End Property

    ReadOnly Property NumberLinkCollectionNodes() As UShort
        Get
            Return _capa.NumberLinkCollectionNodes
        End Get
    End Property

    ReadOnly Property NumberInputButtonCaps() As UShort
        Get
            Return _capa.NumberInputButtonCaps
        End Get
    End Property

    ReadOnly Property NumberInputValueCaps() As UShort
        Get
            Return _capa.NumberInputValueCaps
        End Get
    End Property

    ReadOnly Property NumberInputDataIndices() As UShort
        Get
            Return _capa.NumberInputDataIndices
        End Get
    End Property

    ReadOnly Property NumberOutputButtonCaps() As UShort
        Get
            Return _capa.NumberOutputButtonCaps
        End Get
    End Property

    ReadOnly Property NumberOutputValueCaps() As UShort
        Get
            Return _capa.NumberOutputValueCaps
        End Get
    End Property

    ReadOnly Property NumberOutputDataIndices() As UShort
        Get
            Return _capa.NumberOutputDataIndices
        End Get
    End Property

    ReadOnly Property NumberFeatureButtonCaps() As UShort
        Get
            Return _capa.NumberFeatureButtonCaps
        End Get
    End Property

    ReadOnly Property NumberFeatureValueCaps() As UShort
        Get
            Return _capa.NumberFeatureValueCaps
        End Get
    End Property

    ReadOnly Property NumberFeatureDataIndices() As UShort
        Get
            Return _capa.NumberFeatureDataIndices
        End Get
    End Property

    Public ReadOnly Property UsagePageString() As String
        Get
            Return _UsagePageString
        End Get
    End Property

    Public ReadOnly Property UsageIDString() As String
        Get
            Return _UsageIDString
        End Get
    End Property

    Public Overrides Function ToString() As String
        Dim str As String = ""

        str &= "HIDDeviceCapabilities:" & vbCrLf
        str &= "   UsagePage: 0x" & Me.UsagePage.ToString("X") & " - " & Me.UsagePageString & vbCrLf
        str &= "   UsageID: 0x" & Me.Usage.ToString("X") & " - " & Me.UsageIDString & vbCrLf
        str &= "   InputReportByteLength: " & Me.InputReportByteLength.ToString("") & vbCrLf
        str &= "   OutputReportByteLength: " & Me.OutputReportByteLength.ToString("") & vbCrLf
        str &= "   FeatureReportByteLength: " & Me.FeatureReportByteLength.ToString("") & vbCrLf
        str &= "   NumberLinkCollectionNodes: " & Me.NumberLinkCollectionNodes.ToString("") & vbCrLf
        str &= "   NumberInputButtonCaps: " & Me.NumberInputButtonCaps.ToString("") & vbCrLf
        str &= "   NumberInputValueCaps: " & Me.NumberInputValueCaps.ToString("") & vbCrLf
        str &= "   NumberInputDataIndices: " & Me.NumberInputDataIndices.ToString("") & vbCrLf
        str &= "   NumberOutputButtonCaps: " & Me.NumberOutputButtonCaps.ToString("") & vbCrLf
        str &= "   NumberOutputValueCaps: " & Me.NumberOutputValueCaps.ToString("") & vbCrLf
        str &= "   NumberOutputDataIndices: " & Me.NumberOutputDataIndices.ToString("") & vbCrLf
        str &= "   NumberFeatureButtonCaps: " & Me.NumberFeatureButtonCaps.ToString("") & vbCrLf
        str &= "   NumberFeatureValueCaps: " & Me.NumberFeatureValueCaps.ToString("") & vbCrLf
        str &= "   NumberFeatureDataIndices: " & Me.NumberFeatureDataIndices.ToString("") & vbCrLf

        Return str.ToString
    End Function
End Class
